<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="com.sims.user.UserDAO"%>
<%@ page import="com.sims.vo.UserType"%>
<%@ page import="java.util.ArrayList"%>

<html>
<head>
	<title>学生信息管理系统</title>
	
	<link rel="stylesheet" href="/sims/css/sims_main.css" type="text/css" />
	<link rel="stylesheet" href="/sims/css/sims_tab.css" type="text/css" />
	<link rel="stylesheet" href="/sims/css/sims_table.css" type="text/css" />

	<style type="text/css">
		p {color: white;font-weight: bold;}
	</style>
</head>

<body>
		<% 
		    String userName=(String)session.getAttribute("username");
			int[] userrights = (int[])session.getAttribute("userrights");
			UserDAO ud = new UserDAO();
		    if (userName != null && ud.checkUserInfo(userName))
		    {
		%>
		    	<div id="header">
				<span id="logoTxt" class="logo">&nbsp;学生信息管理系统</span>
				<span id="loginname" class="username">当前用户：
				<%
					out.println(userName);
				%>
				&nbsp;&nbsp;</span>
				<a class="logout" href="/sims/pages/logout.jsp">注销</a>
				</div>

				<div id="menu">
				<ul id="tab">
					<% 
						if (userrights[0]==1)
						{
					%>
					<li><a href="/sims/pages/default.jsp">信息管理</a></li>
					<% 
						}
						if (userrights[1]==1)
						{
					%>
					<li><a href="/sims/pages/changepwd.jsp">密码管理</a></li>
					<% 
						}
						if (userrights[2]==1)
						{
					%>
					<li><a href="/sims/pages/right.jsp">权限管理</a></li>
					<% 
						}
					%>
				</ul>
				</div>

				<div id="content">
					<form action="creatuser.do" method="POST">
					<table align="left" style="margin-left: 10px;">
					<tr>
 					  	<td>
 					  		<input type="submit" value ="保&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;存"/>
 					  		<input type="button" value ="返&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;回" onClick="location.href='/sims/pages/default.jsp'"/>
  					 	</td>
					</tr>
					<tr>
   						<th>学&nbsp;&nbsp;&nbsp;&nbsp;号<input required type="text" maxlength="20" name="userid" placeholder="请输入10位以内的数字和英文字符" style="width:275px;margin-left: 25px;"></th>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<th>姓&nbsp;&nbsp;&nbsp;&nbsp;名<input required type="text" maxlength="20" name="username" placeholder="姓名" style="width:275px;margin-left: 25px;"></th>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<th>性&nbsp;&nbsp;&nbsp;&nbsp;别
   							<input type="radio" name="usersex" value="male" style="margin-left: 15px;" checked />男
   							<input type="radio" name="usersex" value="female">女&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
   						</th>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
					   	<th>学&nbsp;&nbsp;&nbsp;&nbsp;院<input required type="text" maxlength="20" name="usercollage" placeholder="学院" style="width:275px;margin-left: 25px;"></th>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<td></td>
					</tr>
					<tr>
   						<th>专&nbsp;&nbsp;&nbsp;&nbsp;业<input required type="text" maxlength="20" name="userspecialty" placeholder="专业" style="width:275px;margin-left: 25px;"></th>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<th>账号类型<select required name="usertype" style="width:275px;margin-left: 25px;" />
					   	<%
            			ArrayList<UserType> rights = ud.queryRights();
            			for(int i = 0 ; i<rights.size();i++) 
            			{
            				UserType right = rights.get(i);
               			%>
                		<option value="<%=right.getUserTypeId()%>"><%=right.getUserTypeId()%></option>
             			<%
             			}
             			%>
					   	</th>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<td></td>
					</tr>
					<tr>
					   	<th>备&nbsp;&nbsp;&nbsp;&nbsp;注<input required type="text" maxlength="20" name="userdesc" placeholder="备注" style="width:275px;margin-left: 25px;"></th>
					</tr>
					</table>
					</form>
				</div>

				<div id="footer">Copyright no right</div>
				<% 
						String errMsg = (String)request.getSession().getAttribute("Message");
						if (errMsg != null)
						{
							out.println("<SCRIPT LANGUAGE='JavaScript'>");
							out.println("alert('"+errMsg+"')");
							out.println("</SCRIPT>");
							request.getSession().removeAttribute("Message");
						}
				%>
		<%
		    }
		    else
		    {
		    	response.sendRedirect("/sims/index.jsp");
		    }
		%>		
</body>
</html>